js data php

27

// In your controller
if(isset($_POST)){

    $obj = new MyObject();
    $obj->name = $_POST['name'];
    $obj->date = date("Y-m-d");
    $obj->validatePost();
    $obj->update();

    $result = $obj->getData();
    return $result;

}


// Your model
class MyObject {

    public $name;
    public $date;

    public function validatePost(){
        if($this->name == null){
            // print error
        }
    }

    public function update(){
        // database cheets
    }

    public function getData(){
        return $json;
    }

}

Comments

Submit
0 Comments